from django.db import models
#from django import forms
#from django.contrib.flatpages.models import FlatPage
from django.forms import ModelForm, Textarea

class Partition(models.Model):
	name = models.CharField(max_length=128)
	name.help_text = "partition name is case sensitive"

	def __unicode__(self):
		return self.name


class LoadBalancer(models.Model):
	IP = models.CharField(max_length=128)
	partitions = models.ManyToManyField(Partition)

	def __unicode__(self):
		return self.IP


class Link(models.Model):
	name = models.CharField(max_length=128)
	name.help_text = "Display name of link in interface"
	link = models.CharField(max_length=2048)
	link.help_text = "url for the link"
	partition = models.ForeignKey(Partition)
	loadbalancer = models.ForeignKey(LoadBalancer)

	def __unicode__(self):
	        return self.name


class LinkForm(ModelForm):
	class Meta:
		model = Link
		fields = ('name','link','partition','loadbalancer')
		widgets = {
			'link': Textarea(attrs={'cols':80, 'rows': 20}),
		}
